From: Ewan Mellor Date: Thu, 15 Mar 2007 21:44:20 +0000 (+0000) Subject: Allow the xm configuration file location to be overridden with an X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15282^2~62 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=f918e26c26e5664e08dd82f6b3d45ba3936c828a;p=xen.git Allow the xm configuration file location to be overridden with an environment variable. Signed-off-by: Ewan Mellor --- diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index 152c1a69f7..5003ef16fe 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -60,7 +60,8 @@ import XenAPI if not hasattr(getopt, 'gnu_getopt'): getopt.gnu_getopt = getopt.getopt -XM_CONFIG_FILE = '/etc/xen/xm-config.xml' +XM_CONFIG_FILE_ENVVAR = 'XM_CONFIG_FILE' +XM_CONFIG_FILE_DEFAULT = '/etc/xen/xm-config.xml' # Supported types of server SERVER_LEGACY_XMLRPC = 'LegacyXMLRPC' @@ -351,13 +352,14 @@ all_commands = (domain_commands + host_commands + scheduler_commands + # Configuration File Parsing ## +xmConfigFile = os.getenv(XM_CONFIG_FILE_ENVVAR, XM_CONFIG_FILE_DEFAULT) config = None -if os.path.isfile(XM_CONFIG_FILE): +if os.path.isfile(xmConfigFile): try: - config = xml.dom.minidom.parse(XM_CONFIG_FILE) + config = xml.dom.minidom.parse(xmConfigFile) except: print >>sys.stderr, ('Ignoring invalid configuration file %s.' % - XM_CONFIG_FILE) + xmConfigFile) def parseServer(): if config: